/*
 * sanity1.c
 *
 *  Created on: Jun 7, 2014
 *      Author: eran
 */

#include "types.h"
#include "stat.h"
#include "user.h"




int
main(int argc, char *argv[])
{
	int i;
	char buf[1024];
	printf(1, "Opened a.txt\n");
	int fd = open("a.txt", 0x202);
	if (fd == -1){
		printf(2, "Unable to open a.txt\n");
		exit();
	}
	printf(1, "Opened a.txt\n");
	printf(1, "Begin writing bytes\n");
	for(i = 0; i < 6; i++)
		if(write(fd, buf, 1024) < 1024){
			printf(2, "Failed\n");
			close(fd);
			exit();
		}
	printf(1, "Finished writing 6KB\n");
	for(; i < 70; i++)
		if(write(fd, buf, 1024) < 1024){
			printf(2, "Failed\n");
			close(fd);
			exit();
		}
	printf(1, "Finished writing 70KB\n");
	for(; i < 1024; i++)
		if(write(fd, buf, 1024) < 1024){
			printf(2, "Failed\n");
			close(fd);
			exit();
		}

	printf(1, "Finished writing 1MB\n");

	close(fd);
	exit();
}
